Constructors & Destructors
            Constructor is a special member function, because whose name is the same as class name.

  1. Class name and function name same
  2. They will execute automatically when an object is instantiated.
  3. They do not have any return type.
  4. They can overload
  5. Usually constructors are use for initializations, opening files, connections etc.
  6. They must be in public.
  7. They cannot be inherited though a derived class constructor can call the base class constructor using base keyword.
  8. Destructors also execute automatically.
  9. Destructor name is same as class name with ~ prefix.
  10. Generally destructors are used to close the connections, etc.

Program on Constructors
using System;
class abc
{
int a,b;
public abc()
{
Console.WriteLine("Enter 2 nos");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
}
public void put()
{
Console.WriteLine("Sum" + (a + b));
}

}
class sample
{
public static void Main()
{
abc x = new abc();
x.put();
}
}

Program on Parameterized constructor
using System;
class abc
{
int a,b;
public abc(int x,int y)
{
a = x;
b = y;

    }
public void put()
{
Console.WriteLine("Sum" + (a + b));
}

}
class sample
{
public static void Main()
{
abc x = new abc(4,5);
x.put();
}
}
Program on over loading Constructors.
using System;
class abc
{
int a,b;
public abc()
{
Console.WriteLine("Default Constructor");
}

    public abc(int x,int y)
{
a = x;
b = y;

    }
public abc(int x, double y)
{
Console.WriteLine("Sum" + (x + y));
}
public void put()
{
Console.WriteLine("Sum" + (a + b));
}

}
class sample
{
public static void Main()
{
abc x = new abc(4,5);
abc y = new abc();
abc z = new abc(4, 7.2);

        x.put();
}
}
Program on to find the area of triangle, circle, and simple interest using constructors.

Program on destructors
using System;

class abc
{

public abc()
{
Console.WriteLine("Constructor created");

}
~abc()
{

Console.WriteLine("This is Destructor");

    }

}
class sample
{
public static void Main()
{
abc x = new abc();
abc y = new abc();
{
abc z = new abc();
}
}
}